<template>
    <div id="app">
      <div class="card-container">
        <div v-for="(config, index) in formConfig" 
             :key="index"
             class="card" 
             :class="{ active: currentCard === index }" 
             @click="currentCard = index">
          {{ config.label }}
        </div>
      </div>
  
      <div class="dynamic-form">
        <dynamic-input
          :type="formConfig[currentCard].type"
          :label="formConfig[currentCard].label"
          :placeholder="formConfig[currentCard].placeholder"
          :options="formConfig[currentCard].options"
        />
      </div>
    </div>
  </template>
  
  <script>
  import DynamicInput from './components/DynamicInput.vue'
  
  export default {
    name: 'App',
    components: {
      DynamicInput
    },
    data() {
      return {
        currentCard: 0,
        formConfig: [
          {
            type: 'text',
            label: '文本输入框',
            placeholder: '请输入文本',
            options: null
          },
          {
            type: 'checkbox',
            label: '复选框',
            placeholder: '',
            options: ['选项A', '选项B', '选项C']
          },
          {
            type: 'textarea',
            label: '文本域',
            placeholder: '请输入多行文本',
            options: null
          },
          {
            type: 'radio',
            label: '单选按钮组',
            placeholder: '',
            options: ['选项一', '选项二', '选项三', '选项四']
          },
          {
            type: 'select',
            label: '下拉选择框',
            placeholder: '请选择',
            options: ['选项1', '选项2', '选项3', '选项4', '选项5']
          },
          {
            type: 'date',
            label: '日期选择器',
            placeholder: '请选择日期',
            options: null
          },
          {
            type: 'number',
            label: '数字输入框',
            placeholder: '请输入数字',
            options: null
          },
          {
            type: 'password',
            label: '密码输入框',
            placeholder: '请输入密码',
            options: null
          }
        ]
      }
    }
  }
  </script>
  
  <style>
  #app {
    font-family: Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: #2c3e50;
    margin-top: 60px;
    user-select: none;
  }
  
  .dynamic-form {
    max-width: 600px;
    margin: 20px auto;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  }
  
  .card-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
    padding: 0 20px;
  }
  
  .card {
    padding: 12px 20px;
    background-color: #f5f5f5;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
  }
  
  .card:hover {
    background-color: #e0e0e0;
  }
  
  .card.active {
    background-color: #4CAF50;
    color: white;
  }
  </style>